﻿@{
    ViewData["Title"] = "图片换背景色";
    var msg = ViewData["message"];
    var url = ViewData.ContainsKey("url") ? ViewData["url"].ToString() : "/images/img-0.png";
    var oldPath = ViewData.ContainsKey("oldPath") ? ViewData["oldPath"].ToString() : "";
    var colorStr = ViewData.ContainsKey("colorStr") ? ViewData["colorStr"].ToString() : "";
    var down = ViewData.ContainsKey("url") ? $"/common/DownloadFile?filePath={ViewData["url"].ToString()}" : "javascript:;";

    var colorSelectList = new List<SelectListItem>()
    {
        new SelectListItem(){ Text="红色",Value="Red",Selected=colorStr=="Red"},
        new SelectListItem(){ Text="蓝色",Value="Blue",Selected=colorStr=="Blue"},
        new SelectListItem(){ Text="白色",Value="White",Selected=colorStr=="White"},
        new SelectListItem(){ Text="透明",Value="Transparent",Selected=colorStr=="Transparent"}
    };
}

<div class="content">
    <div class="content-body">
        <div class="tool-title clearfix">
            <h1 class="tool-name">图片换背景色</h1>
        </div>
        <div class="tool-form">
            <div class="alert alert-danger tp10">
                <strong></strong> 请选择上传图片
            </div>
            <form action="/home/imagebackground" method="post" enctype="multipart/form-data">
                <input type="hidden" name="OldPath" value="@oldPath" />
                <div class="img-select">
                    <img src="@(string.IsNullOrWhiteSpace(oldPath)?"/images/img-0.png":oldPath)" id="qr-canvas" width="120" height="120" alt="选择图片" />
                    <input type="file" name="files" accept="image/*" onchange="$('form').submit()" title="选择图片">
                    <p>选择图片</p>
                </div>
                <div class="img-select">
                    @Html.DropDownList("color", colorSelectList, new { @class = "form-control image-select-color", onchange = "$('form').submit()" })
                </div>
                <div class="img-select">
                    <img src="@url" width="120" height="120" alt="效果图" />
                    <div class="wp100 tp10">
                        <a href="@down" class="a-btn" target="_blank">保存</a>
                    </div>
                </div>
                <div id="tool-result" class="hide"></div>
            </form>
        </div>
        <div class="wwads-cn wwads-horizontal" data-id="102" style="max-width:100%"></div>		<div class="tool-info">
            @*<h5>相关知识</h5>
                <p>本工具对图像进行处理，部分浏览器不支持。</p>*@
        </div>

    </div>
</div>
